import os

# 获取根目录
base_dir = os.path.abspath(os.path.dirname(__file__))


# 通用配置
class Config:
    # 秘钥
    SECRET_KEY = os.environ.get('SECRET_KEY') or '123456'

    # 数据库配置
    #逻辑性sql语句自动提交事务(默认为False)
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    #默认为True,追踪对象的修改,并且在控制台显示
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 邮件配置
    MAIL_SERVER = 'smtp.163.com'
    MAIL_USERNAME = '17328768265@163.com'
    MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD') or 'zhihuayu95blake'

    # 配置上传文件目录
    UPLOADED_PHOTOS_DEST = os.path.join(base_dir, 'static/upload')
    # 配置上传文件的大小
    MAX_CONTENT_LENGTH = 1024 * 1024 * 10
    # 额外的初始化
    @staticmethod
    def init_app(app):
        pass


# 开发环境
class DevelopmentConfig(Config):
    SQLALCHEMY_DATABASE_URI = 'mysql://qiqi:Qiqi2018_@rm-j6c7o95747bp853w0so.mysql.rds.aliyuncs.com/aaa'
    SQLALCHEMY_BINDS = {
        'jys': 'mysql://qiqi:Qiqi2018_@rm-j6c7o95747bp853w0so.mysql.rds.aliyuncs.com/jys',
        'qhjy': 'mysql://qiqi:Qiqi2018_@rm-j6c7o95747bp853w0so.mysql.rds.aliyuncs.com/qhjy',
        'wallet': 'mysql://qiqi:Qiqi2018_@rm-j6c7o95747bp853w0so.mysql.rds.aliyuncs.com/wallet',
    }


# 测试环境
class TestConfig(Config):
    SQLALCHEMY_DATABASE_URI = 'mysql://root:root@192.168.1.100/aaa'
    SQLALCHEMY_BINDS = {
        'jys': 'mysql://root:root@192.168.1.100/jys',
        'qhjy': 'mysql://root:root@192.168.1.100/qhjy',
        'wallet': 'mysql://root:root@192.168.1.100/wallet',
    }


# 生产环境
# class ProductionConfig(Config):
#     SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(base_dir, 'weibo.sqlite')


# 定义一个字典。
config = {
    'development': DevelopmentConfig,
    'test': TestConfig,
    # 'production': ProductionConfig,
    'default': TestConfig
}